package com.mad.gdrapps;

import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

/**
 * This is a reusable activity class that displays text only content. Clients should pass data to this class in bundles while starting this activity
 * This class is expected to link only to layout/common_textview_only.xml
 * @author jasmeet
 *
 */

public class DisplayTextOnlyScr extends Activity implements Constants{

	
	public void onCreate(Bundle savedInstanceState){
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.common_textview_only);
		
		Bundle b = getIntent().getBundleExtra(KEY_CONTENT_BUNDLE);
	 
		TextView tv = (TextView)findViewById(R.id.commonTV);
	    tv.setText(getContent(b.getString(KEY_CONTENT_FILE_NAME)));
	    
	    setTitle(b.getString(KEY_CONTENT_TITLE)); 
	    
	}
	
	private String getContent(String fileName){
		
		String fullContent = "System error retrieving content for this topic";
		try {
		   InputStream fis2 = this.getAssets().open(fileName);

	          int size = fis2.available();

	          byte[] buffer = new byte[size];
	          fis2.read(buffer);
	          fis2.close();
	          
	          fullContent = new String(buffer);
	          
	    } catch (IOException ioEx){
			
			ioEx.printStackTrace();
			
		}
	    
	      return fullContent;
			
	          
	}
	
}
